package cn.chenxinjie.hrm.controller;

import cn.chenxinjie.hrm.dto.LoginDto;
import cn.chenxinjie.hrm.dto.refreshTokenDto;
import cn.chenxinjie.hrm.service.ILoginUserService;
import cn.chenxinjie.hrm.util.AjaxResult;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 陈鑫杰
 * @date 2022/3/24 10:53
 */
@RestController
@RequestMapping("/hrm")
public class LoginController {
    @Autowired
    private ILoginUserService loginUserService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody @Valid LoginDto dto){
        return loginUserService.login(dto);
    }

    @PostMapping("/refreshToken")
    public AjaxResult refreshToken(@RequestBody @Valid refreshTokenDto dto){
        System.err.println(dto);
        return loginUserService.refreshToken(dto);
    }
}
